<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/yuwanzi.io/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/yuwanzi.io/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/yuwanzi.io/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/yuwanzi.io/images/logo.svg" color="#222">

<link rel="stylesheet" href="/yuwanzi.io/css/main.css">



<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"suyuhuan.gitee.io","root":"/yuwanzi.io/","images":"/yuwanzi.io/images","scheme":"Muse","version":"8.2.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"Suche...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}};
  </script>
<meta name="description" content="关联映射1. 业务关系分析在进行多表关联查询之前,需要对表结构的关联关系与业务关系进行分析与理解。下图以用户,订单,明细,商品表为例分析:  用户表与订单表 一个用户可以创建多个订单 (一对多) 一个订单只能由一个用户创建(一对一)   订单表与明细表 一个订单可以含有多个订单明细(一对多) 一个订单明细只能对应一个订单(一对一)   明细表与商品表 一个订单明细只能对应一个商品(一对一) 一个">
<meta property="og:type" content="article">
<meta property="og:title" content="MyBatis学习笔记-02">
<meta property="og:url" content="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/12/2016-06-12-mybatis-study%20notes02/index.html">
<meta property="og:site_name" content="玉丸子 | Blog">
<meta property="og:description" content="关联映射1. 业务关系分析在进行多表关联查询之前,需要对表结构的关联关系与业务关系进行分析与理解。下图以用户,订单,明细,商品表为例分析:  用户表与订单表 一个用户可以创建多个订单 (一对多) 一个订单只能由一个用户创建(一对一)   订单表与明细表 一个订单可以含有多个订单明细(一对多) 一个订单明细只能对应一个订单(一对一)   明细表与商品表 一个订单明细只能对应一个商品(一对一) 一个">
<meta property="og:locale">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f4pf96s0tcj209302caa2.jpg">
<meta property="og:image" content="http://ww2.sinaimg.cn/mw690/63503acbjw1f4tl89vexqj20fd0ba74p.jpg">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f4u0a7gs9tj20d709ot8z.jpg">
<meta property="article:published_time" content="2016-06-11T16:00:00.000Z">
<meta property="article:modified_time" content="2020-11-07T00:58:17.000Z">
<meta property="article:author" content="玉丸子">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="MyBatis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://ww3.sinaimg.cn/mw690/63503acbjw1f4pf96s0tcj209302caa2.jpg">


<link rel="canonical" href="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/12/2016-06-12-mybatis-study%20notes02/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh'
  };
</script>
<title>MyBatis学习笔记-02 | 玉丸子 | Blog</title>
  




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

<link rel="alternate" href="/yuwanzi.io/atom.xml" title="玉丸子 | Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Navigationsleiste an/ausschalten" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/yuwanzi.io/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">玉丸子 | Blog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          Inhaltsverzeichnis
        </li>
        <li class="sidebar-nav-overview">
          Übersicht
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%B3%E8%81%94%E6%98%A0%E5%B0%84"><span class="nav-number">1.</span> <span class="nav-text">关联映射</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E4%B8%9A%E5%8A%A1%E5%85%B3%E7%B3%BB%E5%88%86%E6%9E%90"><span class="nav-number">1.1.</span> <span class="nav-text">1. 业务关系分析</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E4%B8%80%E5%AF%B9%E4%B8%80%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2"><span class="nav-number">1.2.</span> <span class="nav-text">2. 一对一关联查询</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-%E4%B8%80%E5%AF%B9%E5%A4%9A%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2"><span class="nav-number">1.3.</span> <span class="nav-text">3. 一对多关联查询</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#4-%E5%A4%9A%E5%AF%B9%E5%A4%9A%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2"><span class="nav-number">1.4.</span> <span class="nav-text">4. 多对多关联查询</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BB%B6%E8%BF%9F%E5%8A%A0%E8%BD%BD"><span class="nav-number">2.</span> <span class="nav-text">延迟加载</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E8%AE%BE%E7%BD%AE%E5%BB%B6%E8%BF%9F%E5%8A%A0%E8%BD%BD"><span class="nav-number">2.1.</span> <span class="nav-text">1. 设置延迟加载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E5%9C%A8association%E4%B8%AD%E4%BD%BF%E7%94%A8%E5%BB%B6%E8%BF%9F%E5%8A%A0%E8%BD%BD"><span class="nav-number">2.2.</span> <span class="nav-text">2. 在association中使用延迟加载</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9F%A5%E8%AF%A2%E7%BC%93%E5%AD%98"><span class="nav-number">3.</span> <span class="nav-text">查询缓存</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E4%B8%80%E7%BA%A7%E7%BC%93%E5%AD%98"><span class="nav-number">3.1.</span> <span class="nav-text">1. 一级缓存</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E4%BA%8C%E7%BA%A7%E7%BC%93%E5%AD%98"><span class="nav-number">3.2.</span> <span class="nav-text">2. 二级缓存</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%BC%80%E5%90%AF%E4%BA%8C%E7%BA%A7%E7%BC%93%E5%AD%98"><span class="nav-number">3.2.1.</span> <span class="nav-text">开启二级缓存</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#MyBatis%E4%B8%8ESpring%E6%95%B4%E5%90%88"><span class="nav-number">4.</span> <span class="nav-text">MyBatis与Spring整合</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">玉丸子</p>
  <div class="site-description" itemprop="description">这里是玉丸子的个人博客,与你一起发现更大的世界。</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/yuwanzi.io/archives">
          <span class="site-state-item-count">68</span>
          <span class="site-state-item-name">Artikel</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/yuwanzi.io/categories/">
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">Kategorien</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/yuwanzi.io/tags/">
        <span class="site-state-item-count">46</span>
        <span class="site-state-item-name">schlagwörter</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh">
    <link itemprop="mainEntityOfPage" href="https://suyuhuan.gitee.io/yuwanzi.io/2016/06/12/2016-06-12-mybatis-study%20notes02/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/yuwanzi.io/images/avatar.gif">
      <meta itemprop="name" content="玉丸子">
      <meta itemprop="description" content="这里是玉丸子的个人博客,与你一起发现更大的世界。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="玉丸子 | Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          MyBatis学习笔记-02
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">Veröffentlicht am</span>

      <time title="Erstellt: 2016-06-12 00:00:00" itemprop="dateCreated datePublished" datetime="2016-06-12T00:00:00+08:00">2016-06-12</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">Bearbeitet am</span>
        <time title="Geändert am: 2020-11-07 08:58:17" itemprop="dateModified" datetime="2020-11-07T08:58:17+08:00">2020-11-07</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">in</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/" itemprop="url" rel="index"><span itemprop="name">后端</span></a>
        </span>
          . 
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
        </span>
          . 
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/yuwanzi.io/categories/%E5%90%8E%E7%AB%AF/Java/MyBatis/" itemprop="url" rel="index"><span itemprop="name">MyBatis</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p><img src="http://ww3.sinaimg.cn/mw690/63503acbjw1f4pf96s0tcj209302caa2.jpg" alt="MyBatis"></p>
<h3 id="关联映射"><a href="#关联映射" class="headerlink" title="关联映射"></a>关联映射</h3><h4 id="1-业务关系分析"><a href="#1-业务关系分析" class="headerlink" title="1. 业务关系分析"></a>1. 业务关系分析</h4><p>在进行多表关联查询之前,需要对表结构的关联关系与业务关系进行分析与理解。<br>下图以用户,订单,明细,商品表为例分析:<br><img src="http://ww2.sinaimg.cn/mw690/63503acbjw1f4tl89vexqj20fd0ba74p.jpg" alt="数据模型分析"></p>
<ul>
<li>用户表与订单表<ul>
<li>一个用户可以创建多个订单 (一对多)</li>
<li>一个订单只能由一个用户创建(一对一)</li>
</ul>
</li>
<li>订单表与明细表<ul>
<li>一个订单可以含有多个订单明细(一对多)</li>
<li>一个订单明细只能对应一个订单(一对一)</li>
</ul>
</li>
<li>明细表与商品表<ul>
<li>一个订单明细只能对应一个商品(一对一)</li>
<li>一个商品可以被包含在多个订单明细中(一对多)</li>
</ul>
</li>
<li>订单表与商品表 (间接关系)<ul>
<li>一个订单可以拥有多个订单明细,而一个订单明细对应一个商品,即一个订单可以拥有多个商品。<ul>
<li>order -&gt; orderdetail -&gt; items 一对多</li>
</ul>
</li>
<li>一个商品可以被包含在多个订单明细中,而一个订单明细对应一个订单,即一个商品可以被包含在多个订单中。<ul>
<li>item -&gt; orderdetail -&gt; order 一对多</li>
</ul>
</li>
<li>订单与商品是多对多关系。</li>
</ul>
</li>
<li>用户表与商品表 (间接关系)<ul>
<li>一个用户可以创建多个订单,一个订单可以对应多个订单明细,一个订单明细对应一个商品,即一个用户可以购买多个商品。<ul>
<li>user -&gt; order -&gt; orderdetail -&gt; item 一对多</li>
</ul>
</li>
<li>一个商品可以被包含在多个订单明细中,一个订单明细对应一个订单,一个订单对应一个用户,即一个商品可以对应多个用户。<ul>
<li>item -&gt; orderdetail -&gt; order -&gt; user 一对多</li>
</ul>
</li>
<li>用户与商品是多对多关系。</li>
</ul>
</li>
</ul>
<h4 id="2-一对一关联查询"><a href="#2-一对一关联查询" class="headerlink" title="2. 一对一关联查询"></a>2. 一对一关联查询</h4><blockquote>
<p>在多表查询时,单表的JavaBean不能满足结果集的映射,所以可以使用继承的方法来扩展JavaBean。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.sun.test.entity;</span><br><span class="line"></span><br><span class="line"><span class="comment">// Orders的扩展类</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">OrdersExtends</span> <span class="keyword">extends</span> <span class="title">Orders</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> User user;</span><br><span class="line"></span><br><span class="line">	<span class="function"><span class="keyword">public</span> User <span class="title">getUser</span><span class="params">()</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> user;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setUser</span><span class="params">(User user)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">this</span>.user = user;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>上面的做法与在Orders类中添加一个User类型的属性作用相同。</p>
<blockquote>
<p>映射文件配置</p>
</blockquote>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">&lt;mapper namespace=<span class="string">&quot;com.sun.test.mapper.OrdersMapper&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">	&lt;!-- selectOrdersAndUserRetMap --&gt;</span><br><span class="line">	&lt;!-- resultMap可以使用extends字段继承一个type一致的resultMap  --&gt;</span><br><span class="line">	&lt;resultMap type=<span class="string">&quot;ordersExtends&quot;</span> id=<span class="string">&quot;selectOrdersAndUserRetMap&quot;</span>&gt;</span><br><span class="line">		&lt;!-- 主键 --&gt;</span><br><span class="line">		&lt;id column=<span class="string">&quot;id&quot;</span> property=<span class="string">&quot;id&quot;</span> /&gt;</span><br><span class="line">		&lt;!-- 其他字段 --&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;user_id&quot;</span> property=<span class="string">&quot;userId&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;number&quot;</span> property=<span class="string">&quot;number&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;createtime&quot;</span> property=<span class="string">&quot;createtime&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;note&quot;</span> property=<span class="string">&quot;note&quot;</span>/&gt;  </span><br><span class="line">		&lt;!-- association:一对一映射</span><br><span class="line">			 	property:关联对象在JavaBean中封装的属性名</span><br><span class="line">			 	javaType:关联对象的Java类型</span><br><span class="line">		 --&gt;</span><br><span class="line">		&lt;association property=<span class="string">&quot;user&quot;</span> javaType=<span class="string">&quot;com.sun.test.entity.User&quot;</span>&gt;</span><br><span class="line">			&lt;id column=<span class="string">&quot;user_id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">			&lt;result column=<span class="string">&quot;username&quot;</span> property=<span class="string">&quot;username&quot;</span>/&gt;</span><br><span class="line">			&lt;result column=<span class="string">&quot;address&quot;</span> property=<span class="string">&quot;address&quot;</span>/&gt;			</span><br><span class="line">		&lt;/association&gt; </span><br><span class="line">	&lt;/resultMap&gt;</span><br><span class="line">	</span><br><span class="line">	&lt;!-- 查询订单与用户信息 --&gt;</span><br><span class="line">	&lt;select id=<span class="string">&quot;selectOrdersAndUser&quot;</span> resultMap=<span class="string">&quot;selectOrdersAndUserRetMap&quot;</span>&gt;</span><br><span class="line">		SELECT</span><br><span class="line">			orders<span class="selector-class">.id</span>,</span><br><span class="line">			orders<span class="selector-class">.user_id</span>,</span><br><span class="line">			orders<span class="selector-class">.number</span>,</span><br><span class="line">			orders<span class="selector-class">.createtime</span>,</span><br><span class="line">			orders<span class="selector-class">.note</span>,</span><br><span class="line">			`user`<span class="selector-class">.username</span>,</span><br><span class="line">			`user`.address</span><br><span class="line">		FROM</span><br><span class="line">			orders,</span><br><span class="line">			`user`</span><br><span class="line">		WHERE orders<span class="selector-class">.user_id</span> = `user`.id</span><br><span class="line">	&lt;/select&gt;</span><br><span class="line">	</span><br><span class="line">&lt;/mapper&gt;</span><br></pre></td></tr></table></figure>
<h4 id="3-一对多关联查询"><a href="#3-一对多关联查询" class="headerlink" title="3. 一对多关联查询"></a>3. 一对多关联查询</h4><blockquote>
<p>一对多查询与一对一查询类似,我们要查询商品以及订单明细则需要在商品类中扩展一个List集合。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Items</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> Integer id;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> Float price;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String pic;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> Date createtime;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> String detail;</span><br><span class="line">    </span><br><span class="line">    <span class="comment">// 一对多  一个商品对应多个订单明细</span></span><br><span class="line">    <span class="keyword">private</span> List&lt;Orderdetail&gt; orderdetails;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>映射文件配置</p>
</blockquote>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">&lt;mapper namespace=<span class="string">&quot;com.sun.test.mapper.ItemsMapper&quot;</span>&gt;</span><br><span class="line"></span><br><span class="line">	&lt;!-- (一对多)查询商品以及对应的订单明细 --&gt;</span><br><span class="line">	&lt;select id=<span class="string">&quot;selectItemsAndOrderdetail&quot;</span> resultMap=<span class="string">&quot;selectItemsAndOrderdetailRetMap&quot;</span>&gt;</span><br><span class="line">		SELECT</span><br><span class="line">			items<span class="selector-class">.id</span>,</span><br><span class="line">			items.`name`,</span><br><span class="line">			items<span class="selector-class">.price</span>,</span><br><span class="line">			orderdetail<span class="selector-class">.id</span> orderdetail_id,</span><br><span class="line">			orderdetail.items_num</span><br><span class="line">		FROM</span><br><span class="line">			items,</span><br><span class="line">			orderdetail</span><br><span class="line">		WHERE</span><br><span class="line">			items.id = orderdetail.items_id;</span><br><span class="line">	&lt;/select&gt;</span><br><span class="line"></span><br><span class="line">	&lt;!-- selectItemsAndOrderdetailRetMap --&gt;</span><br><span class="line">	&lt;resultMap type=<span class="string">&quot;items&quot;</span> id=<span class="string">&quot;selectItemsAndOrderdetailRetMap&quot;</span>&gt;</span><br><span class="line">		&lt;id column=<span class="string">&quot;id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;name&quot;</span> property=<span class="string">&quot;name&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;price&quot;</span> property=<span class="string">&quot;price&quot;</span>/&gt;</span><br><span class="line">		&lt;!-- 一对多关联</span><br><span class="line">			 collection:一对多映射</span><br><span class="line">			 	ofType:这个集合参数的类型</span><br><span class="line">		 --&gt;</span><br><span class="line">		 &lt;collection property=<span class="string">&quot;orderdetails&quot;</span> ofType=<span class="string">&quot;orderdetail&quot;</span>&gt;</span><br><span class="line">		 	&lt;id column=<span class="string">&quot;orderdetail_id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">		 	&lt;result column=<span class="string">&quot;items_num&quot;</span> property=<span class="string">&quot;itemsNum&quot;</span>/&gt;</span><br><span class="line">		 &lt;/collection&gt;</span><br><span class="line">	&lt;/resultMap&gt;</span><br><span class="line"></span><br><span class="line">&lt;/mapper&gt;</span><br></pre></td></tr></table></figure>
<h4 id="4-多对多关联查询"><a href="#4-多对多关联查询" class="headerlink" title="4. 多对多关联查询"></a>4. 多对多关联查询</h4><blockquote>
<p>查询商品以及对应的用户信息。</p>
<ol>
<li>在商品类中添加一个订单明细集合(一个商品对应多个订单明细)</li>
<li>在订单明细类中添加一个订单属性(一个订单明细对应一个订单)</li>
<li>在订单类中添加一个用户属性(一个订单对应一个用户)</li>
</ol>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 一对多  一个商品对应多个订单明细</span></span><br><span class="line"><span class="keyword">private</span> List&lt;Orderdetail&gt; orderdetails;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 一对一 一个订单明细对应一个订单</span></span><br><span class="line"><span class="keyword">private</span> Orders orders;</span><br><span class="line"></span><br><span class="line"><span class="comment">//一对一 一个订单对应一个用户</span></span><br><span class="line"><span class="keyword">private</span> User user;</span><br></pre></td></tr></table></figure>
<blockquote>
<p>映射文件配置</p>
</blockquote>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- 查询商品以及对应的用户 --&gt;</span><br><span class="line">&lt;select id=<span class="string">&quot;selectItemsAndUser&quot;</span> resultMap=<span class="string">&quot;selectItemsAndUserRetMap&quot;</span>&gt;</span><br><span class="line">	SELECT</span><br><span class="line">		items<span class="selector-class">.id</span>,</span><br><span class="line">		items.`name`,</span><br><span class="line">		items<span class="selector-class">.price</span>,</span><br><span class="line">		`user`<span class="selector-class">.id</span> user_id,</span><br><span class="line">		`user`<span class="selector-class">.username</span>,</span><br><span class="line">		`user`<span class="selector-class">.address</span>,</span><br><span class="line">		orderdetail<span class="selector-class">.id</span> orderdetail_id,</span><br><span class="line">		orders<span class="selector-class">.id</span> orders_id</span><br><span class="line">	FROM</span><br><span class="line">		items,</span><br><span class="line">		orderdetail,</span><br><span class="line">		orders,</span><br><span class="line">		`user`</span><br><span class="line">	WHERE</span><br><span class="line">		items<span class="selector-class">.id</span> = orderdetail.items_id</span><br><span class="line">	AND orderdetail<span class="selector-class">.orders_id</span> = orders.id</span><br><span class="line">	AND orders<span class="selector-class">.user_id</span> = `user`.id</span><br><span class="line">&lt;/select&gt;</span><br><span class="line"></span><br><span class="line">&lt;!-- selectItemsAndUserRetMap --&gt;</span><br><span class="line">&lt;resultMap type=<span class="string">&quot;items&quot;</span> id=<span class="string">&quot;selectItemsAndUserRetMap&quot;</span>&gt;</span><br><span class="line">	&lt;id column=<span class="string">&quot;id&quot;</span> property=<span class="string">&quot;id&quot;</span> /&gt;</span><br><span class="line">	&lt;result column=<span class="string">&quot;name&quot;</span> property=<span class="string">&quot;name&quot;</span>/&gt;</span><br><span class="line">	&lt;result column=<span class="string">&quot;price&quot;</span> property=<span class="string">&quot;price&quot;</span>/&gt;</span><br><span class="line">	&lt;!-- 一个商品对应多个订单明细  --&gt;</span><br><span class="line">	&lt;collection property=<span class="string">&quot;orderdetails&quot;</span> ofType=<span class="string">&quot;orderdetail&quot;</span>&gt;</span><br><span class="line">		&lt;id column=<span class="string">&quot;orderdetail_id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">		&lt;!-- 一个订单明细对应一个订单 --&gt;</span><br><span class="line">		&lt;association property=<span class="string">&quot;orders&quot;</span> javaType=<span class="string">&quot;orders&quot;</span>&gt;</span><br><span class="line">			&lt;id column=<span class="string">&quot;orders_id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">			&lt;!-- 一个订单对应一个用户 --&gt;</span><br><span class="line">			&lt;association property=<span class="string">&quot;user&quot;</span> javaType=<span class="string">&quot;user&quot;</span>&gt;</span><br><span class="line">				&lt;id column=<span class="string">&quot;user_id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">				&lt;result column=<span class="string">&quot;username&quot;</span> property=<span class="string">&quot;username&quot;</span>/&gt;</span><br><span class="line">				&lt;result column=<span class="string">&quot;address&quot;</span> property=<span class="string">&quot;address&quot;</span>/&gt;</span><br><span class="line">			&lt;/association&gt;</span><br><span class="line">		&lt;/association&gt;</span><br><span class="line">	&lt;/collection&gt;</span><br><span class="line">&lt;/resultMap&gt;</span><br></pre></td></tr></table></figure>
<h3 id="延迟加载"><a href="#延迟加载" class="headerlink" title="延迟加载"></a>延迟加载</h3><p>resultMap中的association和collection具有延迟加载的功能。</p>
<blockquote>
<p>延迟加载: 先加载主信息,在需要的时候加载关联信息,延迟加载即叫按需加载,也叫懒加载。</p>
</blockquote>
<h4 id="1-设置延迟加载"><a href="#1-设置延迟加载" class="headerlink" title="1. 设置延迟加载"></a>1. 设置延迟加载</h4><blockquote>
<p><code>MyBatis</code> 默认是关闭延迟加载的,需要在配置文件中的<settings>标签中手动开启。</p>
</blockquote>
<table>
<thead>
<tr>
<th>settings</th>
<th>description</th>
<th>验证值组</th>
<th>默认值</th>
</tr>
</thead>
<tbody><tr>
<td>lazyLoadingEnabled</td>
<td>全局性设置懒加载。</td>
<td>true</td>
<td>false</td>
</tr>
<tr>
<td>aggressiveLazyLoading</td>
<td>积极性的懒加载,false则是按需加载</td>
<td>true</td>
<td>false</td>
</tr>
</tbody></table>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;settings&gt;</span><br><span class="line">	&lt;!-- 开启延迟加载 ,默认值true--&gt;</span><br><span class="line">	&lt;setting name=<span class="string">&quot;lazyLoadingEnabled&quot;</span> value=<span class="string">&quot;true&quot;</span>/&gt;</span><br><span class="line">	&lt;!-- 设置积极的懒加载,默认值true --&gt;</span><br><span class="line">	&lt;setting name=<span class="string">&quot;aggressiveLazyLoading&quot;</span> value=<span class="string">&quot;false&quot;</span>/&gt;</span><br><span class="line">&lt;/settings&gt;</span><br></pre></td></tr></table></figure>
<h4 id="2-在association中使用延迟加载"><a href="#2-在association中使用延迟加载" class="headerlink" title="2. 在association中使用延迟加载"></a>2. 在association中使用延迟加载</h4><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- 查询订单 并延迟加载用户信息 --&gt;</span><br><span class="line">	&lt;select id=<span class="string">&quot;selectOrdersAndLazyLoadingUser&quot;</span> resultMap=<span class="string">&quot;selectOrdersAndLazyLoadingUserRetMap&quot;</span>&gt;</span><br><span class="line">		SELECT * FROM orders</span><br><span class="line">	&lt;/select&gt;</span><br><span class="line">	</span><br><span class="line">	&lt;!-- selectOrdersAndLazyLoadingUserRetMap --&gt;</span><br><span class="line">	&lt;resultMap type=<span class="string">&quot;orders&quot;</span> id=<span class="string">&quot;selectOrdersAndLazyLoadingUserRetMap&quot;</span>&gt;</span><br><span class="line">		&lt;id column=<span class="string">&quot;id&quot;</span> property=<span class="string">&quot;id&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;user_id&quot;</span> property=<span class="string">&quot;userId&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;number&quot;</span> property=<span class="string">&quot;number&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;createtime&quot;</span> property=<span class="string">&quot;createtime&quot;</span>/&gt;</span><br><span class="line">		&lt;result column=<span class="string">&quot;note&quot;</span> property=<span class="string">&quot;note&quot;</span>/&gt;</span><br><span class="line">		&lt;!-- 一对一关联并延迟加载用户信息</span><br><span class="line">			select:指定延迟加载执行的statementId</span><br><span class="line">			(如果这个statement不在当前namespace中那么则需要使用namespace.statementid)</span><br><span class="line">			column:需要关联查询的列，如果需要传入多个则需要使用 &#123;user_id=id,...&#125;的格式</span><br><span class="line">		 --&gt;</span><br><span class="line">		&lt;association property=<span class="string">&quot;user&quot;</span> column=<span class="string">&quot;user_id&quot;</span> </span><br><span class="line">			select=<span class="string">&quot;com.sun.test.mapper.UserMapper.findById&quot;</span>&gt;&lt;/association&gt;</span><br><span class="line">	&lt;/resultMap&gt;</span><br></pre></td></tr></table></figure>
<h3 id="查询缓存"><a href="#查询缓存" class="headerlink" title="查询缓存"></a>查询缓存</h3><h4 id="1-一级缓存"><a href="#1-一级缓存" class="headerlink" title="1. 一级缓存"></a>1. 一级缓存</h4><blockquote>
<p>一级缓存是SqlSession级别的缓存。在操作数据库时需要构造 sqlSession对象，在对象中有一个数据结构（HashMap）用于存储缓存数据。不同的sqlSession之间的缓存数据区域（HashMap）是互相不影响的。</p>
</blockquote>
<p><img src="http://ww3.sinaimg.cn/mw690/63503acbjw1f4u0a7gs9tj20d709ot8z.jpg"></p>
<blockquote>
<p>当第一次查询对象1时,将先会去一级缓存中查找是否有对象1的数据信息,如果没有则从数据库中查询到数据信息并构造一个key存储到一级缓存(HashMap)中。<br>当第二次查询对象1的时候，则可以凭借key在一级缓存中找到数据信息,而不用再去访问数据库。<br>如果SqlSession进行了事务提交(commit),则会刷新(清空)缓存,目的是为了让缓存存储最新的数据,防止脏读。<br><code>MyBatis</code>默认开启一级缓存。</p>
</blockquote>
<h4 id="2-二级缓存"><a href="#2-二级缓存" class="headerlink" title="2. 二级缓存"></a>2. 二级缓存</h4><blockquote>
<p>二级缓存是<strong>namespace</strong>(mapper)级别的缓存，多个SqlSession去操作同一个<strong>namespace</strong>中的mapper的sql语句，多个SqlSession可以共用二级缓存，二级缓存是跨SqlSession的。<br>二级缓存存储数据不一定是在内存中,所以需要给缓存的对象实现序列化接口。<br>二级缓存需要手动设置开启。</p>
</blockquote>
<h5 id="开启二级缓存"><a href="#开启二级缓存" class="headerlink" title="开启二级缓存"></a>开启二级缓存</h5><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">   在settings中设置</span><br><span class="line">&lt;!-- 开启二级缓存 --&gt;</span><br><span class="line">&lt;setting name=<span class="string">&quot;cacheEnabled&quot;</span> value=<span class="string">&quot;true&quot;</span>/&gt;</span><br><span class="line"></span><br><span class="line">在mapper映射文件中设置</span><br><span class="line">&lt;!-- 使用第三方(ehcache)二级缓存</span><br><span class="line">     flashInterval:设置定时刷新的间隔时间,单位是毫秒。</span><br><span class="line">     注:使用第三方缓存框架需要先导入jar包和整合包</span><br><span class="line">--&gt;</span><br><span class="line">   &lt;cache type=<span class="string">&quot;org.mybatis.caches.ehcache.EhcacheCache&quot;</span> flashInterval=<span class="string">&quot;60000&quot;</span> /&gt;</span><br></pre></td></tr></table></figure>
<h3 id="MyBatis与Spring整合"><a href="#MyBatis与Spring整合" class="headerlink" title="MyBatis与Spring整合"></a>MyBatis与Spring整合</h3><blockquote>
<p>由<code>Spring</code>维护管理数据源、事务、SqlSessionFactory、mapper。<br><code>MyBatis</code>的配置文件只需要配置settings、别名等即可。</p>
</blockquote>
<figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">Spring中的配置</span><br><span class="line">&lt;bean id=<span class="string">&quot;sqlSessionFactory&quot;</span> class=<span class="string">&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;</span>&gt;</span><br><span class="line">	&lt;!-- mybatis的配置文件路径 --&gt;</span><br><span class="line">	&lt;property name=<span class="string">&quot;configLocation&quot;</span> value=<span class="string">&quot;sqlMapConfig.xml&quot;</span>&gt;&lt;/property&gt;</span><br><span class="line">	&lt;!-- 注入数据源 --&gt;</span><br><span class="line">	&lt;property name=<span class="string">&quot;dataSource&quot;</span> ref=<span class="string">&quot;dataSource&quot;</span>&gt;&lt;/property&gt;</span><br><span class="line">&lt;/bean&gt;</span><br><span class="line"></span><br><span class="line">批量生成Mapper(生成的Mapper名字默认为首字母)</span><br><span class="line">&lt;bean class=<span class="string">&quot;org.mybatis.spring.mapper.MapperScannerConfigurer&quot;</span>&gt;</span><br><span class="line">	&lt;!-- 指定需要扫描的mapper配置的包名 --&gt;</span><br><span class="line">	&lt;property name=<span class="string">&quot;basePackage&quot;</span> value=<span class="string">&quot;com.sun.test.mapper&quot;</span>&gt;&lt;/property&gt;</span><br><span class="line">	&lt;!-- 注入SqlSessionFactory --&gt;</span><br><span class="line">	&lt;property name=<span class="string">&quot;sqlSessionFactoryBeanName&quot;</span> value=<span class="string">&quot;sqlSessionFactory&quot;</span>&gt;&lt;/property&gt;</span><br><span class="line">&lt;/bean&gt;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/yuwanzi.io/tags/Java/" rel="tag"># Java</a>
              <a href="/yuwanzi.io/tags/MyBatis/" rel="tag"># MyBatis</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/yuwanzi.io/2016/06/11/2016-06-11-MyBatis-XML%E9%85%8D%E7%BD%AE%E4%B8%8E%E6%98%A0%E5%B0%84%E6%96%87%E4%BB%B6/" rel="prev" title="MyBatis-XML配置与映射文件">
                  <i class="fa fa-chevron-left"></i> MyBatis-XML配置与映射文件
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/yuwanzi.io/2016/06/15/2016-06-15-springmvc-process/" rel="next" title="Spring MVC原理及流程">
                  Spring MVC原理及流程 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>







<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">玉丸子</span>
</div>
  <div class="powered-by">Erstellt mit  <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a>
  </div>

    </div>
  </footer>

  
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/yuwanzi.io/js/utils.js"></script><script src="/yuwanzi.io/js/motion.js"></script><script src="/yuwanzi.io/js/schemes/muse.js"></script><script src="/yuwanzi.io/js/next-boot.js"></script>

  






  





</body>
</html>
